package com.yanqu.road.server.cmd.activity.busyfarming;

import com.yanqu.road.pb.activity.BusyFarmingProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.busyfarming.CrossBusyFarmingMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

import java.util.List;

@Cmd(code = Protocol.C_BUSY_FARMING_ACTIVITY_SYNC_USER_DATA, desc = "玩家果园数据同步")
public class CrossUserDataSyncCmd extends CrossCommand {


    int activityId;

    List<BusyFarmingProto.BusyFarmingUserDataTemp> dataTempList;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        BusyFarmingProto.CrossUserDataSyncMsg syncMsg = BusyFarmingProto.CrossUserDataSyncMsg.parseFrom(packet.getBytes());
        activityId = syncMsg.getActivityId();
        dataTempList = syncMsg.getUserDataList();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CrossBusyFarmingMgr.updateUserData(activityId, serverId, dataTempList);
    }

    @Override
    public void sendData() {

    }
}
